/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Jtable.java
 *
 * Created on May 17, 2011, 1:53:09 AM
 */


/**
 *
 * @author thato
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Jtable extends javax.swing.JFrame {

private String dbAnswers[] = {"A","B","A",null,"C","D","A","C","B",null,null,null,null,null,null,null,null,null,null,"A"};
private String userAnswers[] = {"A","D","A",null,"C","D","A","C","B",null,null,null,null,null,null,null,null,null,null,"C"};
    /** Creates new form Jtable */
    public Jtable() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

	Object test[][] = new Object [20][4];

	for(int i=0; i<20; i++)
        {
		
			test[i][0] = Integer.toString(i);
	}
	
	for(int i=0; i<20; i++)
        {
		
			test[i][1] = dbAnswers[i];
	}

	for(int i=0; i<20; i++)
        {
		
			test[i][2] = userAnswers[i];
	}

	for(int i=0; i<20; i++)
        {
		if(dbAnswers[i] == userAnswers[i] && (dbAnswers[i] != null) && (userAnswers[i]!=null))
		{
			test[i][3] = "Correct";
		}
		else
		{
			test[i][3] = "Wrong";
		}
			
		
	}
                                             

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
	setFont(new java.awt.Font("Ubuntu", 1, 36));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
          test ,
            new String [] {
                "Question Number", "Your Answer", "Correct Answer", "Score"
            }
        )
	{
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>



    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Jtable().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration

}

